//
//  CKADView.swift
//  CKBasic
//
//  Created by 纪洪波 on 2017/9/5.
//  Copyright © 2017年 Zac. All rights reserved.
//

import UIKit

class CKADView: UIView {
    @IBOutlet weak var adView: UIView!
    @IBOutlet weak var viewWidth: NSLayoutConstraint!

    func showAD() {
        self.layoutIfNeeded()
        UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: [], animations: {
            self.alpha = 1
            self.viewWidth.constant = 300
            self.layoutIfNeeded()
        }, completion: nil)
    }
    @IBAction func close(_ sender: Any) {
        UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: [], animations: {
            self.alpha = 0
            self.viewWidth.constant = 0
            self.layoutIfNeeded()
        }, completion: { (finished) in
            self.removeFromSuperview()
        })
    }
}
